package com.ksyzt.ksite2.server.listener;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.ksyzt.ksite2.server.listener.tasks.ZhuJiangWater;

public class SystemTaskSchedure implements ServletContextListener {

	private Timer m_timer;

	public SystemTaskSchedure() {
	}

	@Override
	public void contextDestroyed(ServletContextEvent event) {

		m_timer.cancel();

		event.getServletContext().log("stop task schedure!");
	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		event.getServletContext().log("start task schedure...");
		m_timer = new Timer(true);
		long delay = 0;
		m_timer.scheduleAtFixedRate(new ZhuJiangWater(), delay, 60 * 60 * 1000);
	}
}
